const express = require('express');
const bodyParser = require('body-parser');
const routes = require('./routes');
const logger = require('./logger');
// 引入 cors 模块
const cors = require('cors'); 

const app = express();
app.use(bodyParser.json());

// 使用 cors 中间件，允许所有跨域请求
app.use(cors()); 

app.use(routes);

const port = process.env.PORT || 3000;
app.listen(port, () => {
    logger.info(`服务器运行在端口 ${port}`);
});